package middleware

import (
	"github.com/starmotioncf/soutchatinternal/constant"
	"github.com/starmotioncf/soutchatinternal/service"

	"github.com/gin-gonic/gin"
)

type FilterEntityMiddleware struct {
	settingService service.SettingService
}

func NewFilterEntityMiddleware(settingService service.SettingService) *FilterEntityMiddleware {
	return &FilterEntityMiddleware{
		settingService: settingService,
	}
}

func (m *FilterEntityMiddleware) Handle(ctx *gin.Context) {
	filterEntity := m.settingService.GetFilterEntity(ctx)
	//向context写入用户token信息
	ctx.Set(constant.CtxFilterEntity, filterEntity)
	ctx.Next()
}
